#include <iostream>
#include <algorithm>
using namespace std;
const int N = 200005;
int t, n, maxl, minr;
struct zb{
	int l;
	int r;
};
bool cmp1(zb a, zb b){
	return a.l < b.l;
}
bool cmp2(zb a, zb b){
	return a.r < b.r;
}
struct zb a[N], b[N];
int main(){
	cin >> t;
	while(t--){
		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> a[i].l >> a[i].r;
			b[i].l = a[i].l;
			b[i].r = a[i].r;
		}
		sort(a, a + n, cmp1);
		sort(b, b + n, cmp2);
		int flag = 1;
		for (int i = 0; i < n; i++){
			if (a[i].r != b[i].r || a[i].l != b[i].l){
				flag = 0;
				break;
			}
		}
		if (a[0].r < a[n - 1].l)flag = 0;
		if (flag) cout << "Yes" << endl;
		else cout << "No" << endl;
		
		
	}

    return 0;
}






